<!DOCTYPE html>
<html>
    <head>
        <? require_once 'header.php'; ?>
    </head>
    <body>
        <?
        getNavbar();
        ?>
        <div class="container-fluid">
            <div class="row-fluid" style="margin-top: 40px;">
                <h1 align="center"><? echo $this->getRepublica()->getNome(); ?></h1>
            </div>
            <div class="row-fluid">
                <div class="span9">
                    <div class="navbar">
                        <div class="navbar-inner">
                            <a class="brand" href="#">Descrição</a>
                        </div>
                        <div class="container-fluid well">
                            <div class="span3">
                                <h3 align="center" style="margin: 0px;">Imagens</h3>
                                <?
                                $this->getImagensRepublica($this->getRepublica());
                                ?>
                            </div>
                            <div class="span9">
                                <form class="form-horizontal" action="" method="POST">
                                    <input type="hidden" id="formUpdateRepublica" name="formUpdateRepublica" value="formUpdateRepublica" />
                                    <div class="control-group">
                                        <label class="control-label" for="edtNome">Nome:</label>
                                        <div class="controls">
                                            <input type="text" id="edtNome" name="edtNome" placeholder="Nome" value="<? echo $this->getRepublica()->getNome(); ?> "/>
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label class="control-label" for="edtDescricao">Descrição:</label>
                                        <div class="controls">
                                            <textarea rows="5" id="edtDescricao" name="edtDescricao" placeholder="Descricao"><? echo $this->getRepublica()->getDescricaoEndereco(); ?></textarea>
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label class="control-label" for="edtEndereco">Endereco:</label>
                                        <div class="controls">
                                            <input type="text" id="edtEndereco" name="edtEndereco" placeholder="Endereço" value="<? echo (is_a($this->getRepublica()->getEndereco(), "Endereco")) ? $this->getRepublica()->getEndereco()->getDescricao() : ""; ?> "/>
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label class="control-label" for="edtNumero">Numero:</label>
                                        <div class="controls">
                                            <input type="text" id="edtNumero" name="edtNumero" placeholder="Numero" value="<? echo $this->getRepublica()->getNumero(); ?> "/>
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label class="control-label" for="edtBairro">Bairro:</label>
                                        <div class="controls">
                                            <input type="text" id="edtBairro" name="edtBairro" placeholder="Bairro" value="<? echo (is_a($this->getRepublica()->getBairro(), "Bairro")) ? $this->getRepublica()->getBairro()->getDescricao() : ""; ?> "/>
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label class="control-label" for="edtPais">Pais</label>
                                        <div class="controls">
                                            <select id="edtPais" name="edtPais" required="required">
                                                <?
                                                $dp = new DaoPais();
                                                $paises = $dp->getPaises();
                                                foreach ($paises as $pais) {
                                                    ?>
                                                    <option value="<?php echo $pais->getCodigo(); ?>" <?php if ($pais->getCodigo() == 1) { ?> selected="true"<?php } ?>><?php echo $pais->getNome(); ?></option>
                                                    <?php
                                                }
                                                ?>

                                            </select>
                                            <!--<input type="text" id="edtPais" name="edtPais" placeholder="Pais">-->
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label class="control-label" for="edtEstado">Estado</label>
                                        <div class="controls">
                                            <select id="edtEstado" name="edtEstado" onchange="buscar_cidades();" required="required">
                                                <?
                                                $de = new DaoEstado();
                                                $estados = $de->getEstados();
                                                if ($this->getRepublica()->getCidade()->getCodigo() == NULL) {
                                                    ?>
                                                    <option value='' selected="true">Estado</option>
                                                    <?
                                                }
                                                foreach ($estados as $es) {
                                                    ?>
                                                    <option value="<?php echo $es->getCodigo(); ?>" <?php if ($this->getRepublica()->getCidade()->getCodigo() != NULL) {
                                                    if ($es->getCodigo() == $this->getRepublica()->getCidade()->getEstado()->getCodigo()) { ?> selected="true"<?php }
                                        } ?>><?php echo $es->getNome(); ?></option>
                                                    <?php
                                                }
                                                ?>

                                            </select>
                                            <!--<input type="text" id="edtEstado" name="edtEstado" placeholder="Estado">-->
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label class="control-label" for="edtCidade">Cidade</label>
                                        <div class="controls" id="cidade">
                                            <select id="edtCidade" name="edtCidade" required="required">
                                                <?php
                                                $dc = new DaoCidade();
                                                if ($this->getRepublica()->getCidade()->getCodigo() != NULL) {
                                                    $cidades = $dc->getCidadesByEstado($this->getRepublica()->getCidade()->getEstado()->getCodigo());
                                                    foreach ($cidades as $cid) {
                                                        ?>
                                                        <option value="<?php echo $cid->getCodigo(); ?>"<? if ($cid->getCodigo() == $this->getRepublica()->getCidade()->getCodigo()) { ?> selected="true"<?php } ?>><?php echo $cid->getNome(); ?></option>
                                                        <?php
                                                    }
                                                } else {
                                                    ?>
                                                    <option value=''>Selecione o estado</option>
                                                    <?
                                                }
                                                ?>
                                            </select>
                                            <!--<input type="text" id="edtCidade" name ="edtCidade" placeholder="Cidade">-->
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label class="control-label" for="edtVagas">Vagas:</label>
                                        <div class="controls">
                                            <input type="number" id="edtVagas" name="edtVagas" placeholder="Vagas" value="<? echo $this->getRepublica()->getQuantiaVagas(); ?>"/>
                                        </div>
                                    </div>
                                    <button type="submit" class="btn">Atualizar</button>
                                </form>

                            </div>
                        </div>
                    </div>
                    <div class="navbar">
                        <div class="navbar-inner">
                            <a class="brand" href="#">Comentarios</a>
                        </div>
                        <div class="container-fluid well">
                            <div class="span4 text-center label label-success">
                                <i class="icon-star"> </i><i class="icon-star"> </i><i class="icon-star"> </i><i class="icon-star"> </i><i class="icon-star"> </i>
                                <h1 style="margin-top: 0px;">Nota: 10.0</h1>
                            </div>
                            <div class="span8">
                                <blockquote>
                                    <p>Republica Muito Massa!</p>
                                    <small>Rodrigo Araujo</small>
                                </blockquote>
                                <blockquote>
                                    <p>Notaaaa 100000</p>
                                    <small>Ex Morador</small>
                                </blockquote>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="span3" align="center">
                    <div class="navbar">
                        <div class="navbar-inner">
                            <a class="brand" href="#">Moradores</a>
                        </div>
                        <div class="container-fluid well">
                            <table class="table table-striped">
                                <tr>
                                    <td><img src="/Versao1/img/icon-Empresa.png" style="max-height: 20px; min-height: 20px;"/></td>
                                    <td>Dono</td>
                                </tr>
                                <tr>
                                    <td><img src="/Versao1/img/icon-Empresa.png" style="max-height: 20px; min-height: 20px;"/></td>
                                    <td>Rodrigo Araujo</td>
                                </tr>
                                <tr>
                                    <td><img src="/Versao1/img/icon-Empresa.png" style="max-height: 20px; min-height: 20px;"/></td>
                                    <td>Maluco tres</td>
                                </tr>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <?
        require_once 'footer.php';
        ?>
    </body>
</html>
